from rest_framework import serializers
from certificate_manager.models import DepartRestrict
from certificate_manager.serializers import *

class DepartRestrictSerializer(serializers.ModelSerializer):
        
        class Meta:
                model = DepartRestrict
                fields = ['id', 'department', 'restrict_type', 'people_limit_min', 'people_limit_max', 'priority']
        def to_representation(self, restrict):
            res = super().to_representation(restrict)
            res['department'] = DepartmentSerializer(restrict.department).data
            return res
